﻿@using Presentation.Web.Admin
@model Domain.Dto.TourDto
<div id="divArticle">
    @using (Ajax.BeginForm("add", "tour", new AjaxOptions() { HttpMethod = "post", OnBegin = "checkedAddForm", OnSuccess = "addSuccess", OnFailure = "addFailure" }))
    {
        <fieldset class="module width_full">
            @Html.Partial("_Form", Model)
        </fieldset>  
        <p>
            @{
        if (Html.HasUiPermission(this.ViewContext, "add"))
        { 
                <input type="submit" value="添加" class="alt_btn module_margin" />
        }
            }
        </p>
    }
</div>
<script type="text/javascript">

    function checkedAddForm() {
        var res = true;
        if ($('#Name').val() == "") {
            alert("线路名不能为空");
            $('#Name').focus();
            res = false;
            return res;
        }
        if ($('#Remark').val() == "") {
            alert("描述不能为空");
            $('#Remark').focus();
            res = false;
            return res;
        }
        return res;
    }

    function addSuccess(res) {
        if (res.success) {
            //alert("添加成功");
            window.location.reload();
        }
        else {
            alert(res.message);
        }
    }

    function addFailure() {
        alert("添加失败了T_T！");
    }
</script>
